home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 6828 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.0 KB

  1. Path: keats.ugrad.cs.ubc.ca!not-for-mail
  2. From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: calloc help needed
  5. Date: 15 Feb 1996 08:20:27 -0800
  6. Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
  7. Message-ID: <4fvmgbINNbp0@keats.ugrad.cs.ubc.ca>
  8. References: <1996Feb15.125431.7751@leeds.ac.uk>
  9. NNTP-Posting-Host: keats.ugrad.cs.ubc.ca
  10.  
  11. In article <1996Feb15.125431.7751@leeds.ac.uk>,
  12. A M Casey <csyamc@scs.leeds.ac.uk> wrote:
  13.  >I'm trying to allocate enough memory for an array of strings, defined as
  14.  >char * MyArray[20].
  15.  >the only manual entry I have for calloc says that it needs two values, the
  16.  >number of elements, and the size of each, but how do I actually use it?
  17.  >
  18.  >MyArray = calloc(20,50);
  19.  
  20. This is gives you much more space than you need for the array. A character's
  21. size is not 50!
  22.  
  23.  >doesnt work, as far as I can tell calloc returns an int.
  24.  
  25. It is probably "implicitly defined" to return an int, because you lack a
  26. declaration. Try including the "malloc.h" header file.
  27. -- 
  28.  
  29.